<template>
  <div class="">
    <div>
      <van-search
        v-model="query.name"
        show-action
        placeholder="请输入搜索关键词"
        @search="onSearch"
        @cancel="onCancel"
        input-align="center"
      />
    </div>

    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="getdata"
    >
      <div class="infoview">
        <p @click="clickcpmpany(item.corpId)" v-for="(item,index) in lists" :key="index">{{item.corpName}}</p>
      </div>
    </van-list>
  </div>
</template>

<script>
  import {Toast} from "vant";

  export default {
    data() {
      return {
        lists: [],
        query: {
          pageNum: 1,
          pageSize: 10,
          name: '',
          status: 2
        },
        loading: false,
        finished: false,
      }
    },
    created() {
    },
    methods: {
      getdata() {
        this.$Api.get("/api/corp/findCorpList", this.query).then(res => {
          if (res.data.code == 200) {
            if (res.data.data.result.length > 0) {
              this.lists.push(...res.data.data.result);
              this.query.pageNum++
            } else {
              this.finished = true;
            }
          } else {
            Toast(res.data.message);
          }
          // 加载状态结束
          this.loading = false;
          // 数据全部加载完成
          if (res.data.data.result.length < 10) {
            this.finished = true;
          }
        }).catch(err => {
        });
      },
      clickcpmpany(e) {
        this.$router.push({path: '/enterpriseCar/contract/list', query: {corpId: e}})
      },
      onSearch() {
        this.query.pageNum = 1;
        this.lists = [];
        this.getdata();
      },
      onCancel() {
        this.dataquery.name = '';
        this.query.pageNum = 1;
        this.lists = [];
        this.getdata();
      }
    }
  }
</script>

<style scoped>
  .infoview p {
    padding: 1rem;
    border-bottom: 0.1rem solid rgba(0, 0, 0, 0.1);
  }
</style>
